package com.tian.controller;

import com.tian.pojo.Hospital;
import com.tian.service.HospitalService;
import com.tian.vo.PageResult;
import com.tian.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hospital")
@CrossOrigin
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    @GetMapping("/get")
    public SysResult getList(PageResult pageResult){
        pageResult = hospitalService.getList(pageResult);
        return SysResult.success(pageResult);
    }

    @DeleteMapping("/delete/{id}")
    public SysResult deleteById(@PathVariable Integer id){
        hospitalService.deleteById(id);
        return SysResult.success();
    }



    @GetMapping("/findHospitalList/{type}")
    public SysResult findHospitalList(@PathVariable Integer type){
        List<Hospital> hospitalsList = hospitalService.findItemCatList(type);
        return SysResult.success(hospitalsList);

    }

}
